home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1996 / MacHack 1996.toast / Hacks / Hacks ’92 / Run & Stumpy / source / aelist.cp < prev    next >
Encoding:
Text File  |  1992-06-19  |  1.8 KB  |  114 lines  |  [TEXT/MPS ]

  1. #define SystemSevenOrLater 1
  2.  
  3. #include <errors.h>
  4.  
  5. #include "aelist.h"
  6. #include "templock.h"
  7.  
  8. void aelist::append( DescType type,
  9.                             void *data,
  10.                             uint32 size )
  11.   {
  12.     if (iswrong())
  13.         return;
  14.     
  15.     error= AEPutPtr( this,
  16.                           0,
  17.                           type,
  18.                           (Ptr)data,
  19.                           size );
  20.   }
  21.  
  22. void aelist::append( DescType type,
  23.                             Handle h )
  24.   {
  25.     if (iswrong())
  26.         return;
  27.     
  28.     templock lock(h);
  29.     
  30.     append( type, *h, GetHandleSize(h) );
  31.   }
  32.  
  33. void aelist::append( const AEDesc& item )
  34.   {
  35.     if (iswrong())
  36.         return;
  37.     
  38.     error= AEPutDesc( this, 0, &item );
  39.   }
  40.  
  41. uint32 aelist::countitems()
  42.   {
  43.     uint32 count;
  44.     error= AECountItems( this, (long *)&count );
  45.     return count;
  46.   }
  47.  
  48. OSErr aelist::getnth( uint32 index,
  49.                              DescType desired,
  50.                              AEKeyword& key,
  51.                              DescType& actualtype,
  52.                              void *data,
  53.                              uint32 maxsize,
  54.                              uint32& truesize )
  55.   {
  56.     if (iswrong())
  57.         return whatiswrong();
  58.  
  59.     return AEGetNthPtr( this,
  60.                               index,
  61.                               desired,
  62.                               &key,
  63.                               &actualtype,
  64.                               (Ptr)data,
  65.                               maxsize,
  66.                               (Size *)&truesize );
  67.   }
  68.  
  69. OSErr aelist::getnth( uint32 index,
  70.                              DescType desired,
  71.                              AEKeyword& key,
  72.                              DescType& actualtype,
  73.                              Handle& result )
  74.   {
  75.     uint32 size;
  76.     OSErr error= getnth( index,
  77.                                 desired,
  78.                                 key,
  79.                                 actualtype,
  80.                                 0,
  81.                                 0,
  82.                                 size );
  83.     if ( error != noErr )
  84.         return error;
  85.     
  86.     result= NewHandle(size);
  87.     if ( result==0 )
  88.         return mFulErr;
  89.     
  90.     templock lock(result);
  91.     return getnth( index,
  92.                         desired,
  93.                         key,
  94.                         actualtype,
  95.                         0,
  96.                         0,
  97.                         size );
  98.   }
  99.  
  100. OSErr aelist::getnth( uint32 index,
  101.                              DescType desired,
  102.                              AEKeyword& key,
  103.                              AEDesc& result )
  104.   {
  105.     if (iswrong())
  106.         return whatiswrong();
  107.  
  108.     return AEGetNthDesc( this,
  109.                                 index,
  110.                                 desired,
  111.                                 &key,
  112.                                 &result );
  113.   }
  114.